import type {InjectionKey} from "vue";
import {createStore, Store, useStore as baseUseStore} from "vuex";
import type {State} from "@/store/state";
import {state} from "@/store/state";
import {mutations} from "@/store/mutations";
import {getters} from "@/store/getters";
import {actions} from "@/store/actions";



// 创建一个新的 store 实例
export const store = createStore<State>({
    state() {
        return state;
    },
    mutations,
    getters,
    actions,
});


// 定义 injection key
export const key: InjectionKey<Store<State>> = Symbol();

// 定义自己的 `useStore` 组合式函数
export function useStore() {
    return baseUseStore(key);
}

